package in.muton.edushare.pages.group;

import java.util.List;

import in.muton.edushare.wicket.models.CayenneList;
import in.muton.edushare.wicket.models.InnerList;
import in.muton.panels.paginator.EdushareListView;
import in.muton.panels.paginator.EntityListing;
import in.muton.panels.paginator.badgehelpers.user.GroupBadgeRoles;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.dao.GroupsMembersDAO;
import com.edushare.common.dao.UsersDAO;
import com.edushare.common.vo.GroupMembers;
import com.edushare.common.vo.Users;

public class GroupPeople extends GroupBase {

//	CayenneList<Users> ul;
	
	public GroupPeople(PageParameters params) {
		super(params);
//		ul = new CayenneList<Users>(new GroupsMembersDAO(getSessionORMInterface()).getMembers(super.getGroupModel().getObject(), GroupMembers.STATUS_ACTIVE));
		loadPanel();
	}

	private void loadPanel() {
		WebMarkupContainer cont = new WebMarkupContainer("pplCont");
		add(cont);
		EntityListing<Users> ulv = new EntityListing<Users>(
				"thumbList", 
				new InnerList<Users>(){
										@Override
										public List<IModel<Users>> getObject() {
											return new CayenneList<Users>(
													new GroupsMembersDAO(getSessionORMInterface())
													.getMembers(
																GroupPeople.this.getGroupModel().getObject(), 
																GroupMembers.STATUS_ACTIVE
																)
													).getObject();
										}
									}, 
				new GroupBadgeRoles(super.getGroupModel()), this);
		cont.add(ulv);
	}
	
	public CayenneList<Users> getMembers(){
		return new CayenneList<Users>(new GroupsMembersDAO(getSessionORMInterface()).getMembers(super.getGroupModel().getObject(), GroupMembers.STATUS_ACTIVE));
	}

	@Override
	protected String getActivePage() {
		return "groupPeople";
	}

	@Override
	public String getPageTitle() {
		return "People | " + super.getGroupModel().getObject().getGroupName() + " | " + ApplicationConstants.APPLICATION_NAME;
	}

}
